package dev.alm.cqtakeoutservice.handler;

import dev.alm.cqtakeoutservice.common.CR;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public CR handleException(Exception e) {
        String message = e.getMessage();
        return CR.fail(message);
    }

}
